const express = require('express');
const router = express.Router();


//在此处挂载对应的路由即 get  post  delete
router.get('/get', (req, res) => {
    //拿到客户端通过查询字符串传递过来的参数
    const query = req.query;
    //调用send()方法，返回给客户端
    res.send({
        status: 0,
        message: 'ok',
        data: query,
        msg: 'GET成功'
    });
});

router.post('/post', (req, res) => {
    //拿到客户端通过请求体发送到服务器的URL-encode编码的数据
    const body = req.body;
    //调用send()方法，响应给客户端
    res.send({
        status: 0,
        message: 'ok',
        data: body, //如果想要拿到URL-encode编码的数据，需要配置urlencoded中间件
        msg: 'POST成功'
    });
});

router.delete('/delete', (req, res) => {

});




module.exports = router; //暴露出去